package com.mg.axechen.viewmodel

import android.os.Bundle
import android.widget.Button
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider


class ActivityTwo : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_two)
        val viewModel = ViewModelProvider(BaseApplicaiton.instance!!).get(MyViewModel::class.java)

        val tvContent:TextView = findViewById(R.id.tvContent)
        val btnGetData:Button = findViewById(R.id.btnGetData);

        tvContent.text = viewModel.comonText

        btnGetData.setOnClickListener {
            viewModel.getStringData()
        }
    }
}